package com.kws.merchant.mapper;

import com.kws.merchant.domain.AfterSalesMalfunction;
import com.kws.merchant.domain.Device;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;


/**
 * 商品-设备(Device)表数据库访问层
 *
 * @author yxy
 * @since 2024-10-22 11:03:38
 */

public interface DeviceMapper extends BaseMapper<Device> {


    @Select("SELECT count(*) from tb_device a LEFT JOIN tb_merchant m on a.merchant_id=m.id where 1=1 ${sql};")
    int countToTal(@Param("sql") String sql);

    @Select("SELECT a.*,m.company_name as merchantName from tb_device a LEFT JOIN tb_merchant m on a.merchant_id=m.id  where 1=1 ${sql} limit ${sizeNum},${totalPage}")
    List<Device> getRecords(@Param("sql") String sql, @Param("sizeNum") Integer sizeNum, @Param("totalPage") Integer totalPage);


    @Select("SELECT a.*,m.company_name as merchantName from tb_device a LEFT JOIN tb_merchant m on a.merchant_id=m.id  where a.id=${id};")
    Device detailById(@Param("id") Long id);
}
